package com.xinan.dmgl.cggl;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

import java.util.List;

@TableBind(tableName = "cggl_wp")
public class CgglWp extends Model<CgglWp>{
    public static final CgglWp dao = new CgglWp();

    //columns START
    private String ID = "id";  //主键
    private String WPBH = "wpbh";  //物品编号
    private String WPMC = "wpmc";  //
    private String LBID = "lbid";  //类别id
    private String DSPORDER = "dsporder";  //排序
    private String WPDW = "wpdw";  //物品单位
    private String BZ = "bz";  //备注
    private String CKDJ = "ckdj";  //参考单价
    private String YXBZ = "yxbz";  //有效标志
    private String KCSL="kcsl";//库存数量
    private String WPPY="wppy";//拼音头
    private String SPTC="sptc"; // 商品提成
    private String SPTCFS="sptcfs"; // 商品提成方式
    private String KCSX="kcsx"; // 库存上限
    private String KCXX="kcxx"; // 库存下限

    public void setId(int value) {
        set(ID, value);
    }

	public int getId() {
		return get(ID);
	}
    public void setWpbh(String value) {
        set(WPBH, value);
    }

	public String getWpbh() {
		return get(WPBH);
	}
    public void setWpmc(String value) {
        set(WPMC, value);
    }

	public String getWpmc() {
		return get(WPMC);
	}
    public void setLbid(String value) {
        set(LBID, value);
    }

	public String getLbid() {
		return get(LBID);
	}
    public void setDsporder(int value) {
        set(DSPORDER, value);
    }

	public int getDsporder() {
		return get(DSPORDER);
	}
    public void setWpdw(String value) {
        set(WPDW, value);
    }

	public String getWpdw() {
		return get(WPDW);
	}
    public void setBz(String value) {
        set(BZ, value);
    }

	public String getBz() {
		return get(BZ);
	}
    public void setCkdj(String value) {
        set(CKDJ, value);
    }

	public String getCkdj() {
		return get(CKDJ);
	}
    public void setYxbz(String value) {
        set(YXBZ, value);
    }

	public String getYxbz() {
		return get(YXBZ);
	}

	public String getWPPY() {
		return WPPY;
	}

	public void setWPPY(String wPPY) {
		WPPY = wPPY;
	}
	public String getKCSL() {
		return KCSL;
	}

	public void setKCSL(String kCSL) {
		KCSL = kCSL;
	}

	public String getSPTCFS() {
		return SPTCFS;
	}

	public void setSPTCFS(String sPTCFS) {
		SPTCFS = sPTCFS;
	}

	public String getKCSX() {
		return KCSX;
	}

	public void setKCSX(String kCSX) {
		KCSX = kCSX;
	}

	public String getKCXX() {
		return KCXX;
	}

	public void setKCXX(String kCXX) {
		KCXX = kCXX;
	}

	public String getSPTC() {
		return SPTC;
	}

	public void setSPTC(String sPTC) {
		SPTC = sPTC;
	}

	
	//columns END

    public List<CgglWp> findAll() {
        return find("select * from cggl_wp");
    }

    public Page<CgglWp> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from cggl_wp";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        String order=" order by yxbz desc";
        return paginate(pageNumber, pageSize, "select *", sqlExp+order);
    }

    public Page<CgglWp> pagetj(int pageNumber, int pageSize, String where) {
        String sqlExp = "from cggl_wp b";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        String order=" order by yxbz desc";
        return paginate(pageNumber, pageSize, "select *,(select  sum(wpsl) from cpgl_rk a   where   a.wpid=b.id) as rksl" +
        		",(select  sum(cksl) from cpgl_ck a   where   a.wpid=b.id) as cksl", sqlExp+order);
    }


}

